package com.wave.wavesystem.serve.util;

import com.wave.common.enums.ErrorCode;
import com.wave.common.exception.ReLoginException;
import com.wave.common.exception.WaveException;
import com.wave.common.util.Func;
import
        com.wave.wavesystem.serve.pojo.entity.CurrentUser;



public class CurrentUserUtil {

    private final static ThreadLocal<CurrentUser> currentUser = new ThreadLocal<>();

    public static CurrentUser getCurrentUser() {
        CurrentUser cu = currentUser.get();
        if (Func.isEmpty(cu)) {
            throw new ReLoginException(ErrorCode.REQ_LOGIN);
        }
        return cu;
    }

    public static void setCurrentUser(CurrentUser user) {
        currentUser.set(user);
    }

    public static void removeCurrentUser() {
        currentUser.remove();
    }

}
